<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin-top: 20px;
        }

        .demo1 {
            height: 50px;
            background-color: red;
        }

        .box1 {
            padding: 10px;
            background-color: pink;
        }

        .box2 {
            padding: 10px;
            background-color: yellow;
        }
    </style>
    <script src="../../js/vue.js"></script>
</head>

<body>
    <div id="root">

        <h2>欢迎来到{{name}}学习</h2>

        <!-- 阻止默认事件 -->
        <a href="../01-初识vue.html" @click.prevent="showInfo">点我提示信息</a>

        <!-- 阻止冒泡 -->
        <div @click="showInfo" class="demo1">
            <button @click.stop="showInfo">点我提示信息</button>
        </div>

        <!-- 事件只触发一次 -->
        <button @click.once="showInfo">点我提示信息</button>

        <!-- 事件捕获 -->
        <div class="box1" @click.capture="showMsg(1)">
            div1
            <div class="box2" @click="showMsg(2)">
                div2
            </div>
        </div>

    </div>
    <script>
        Vue.config.productionTip = false //取消生产提示

        const vm = new Vue({
            el: '#root',
            data() {
                return {
                    name: '尚硅谷'
                }
            },
            methods: {
                showInfo() {
                    alert('同学你好!')
                },
                showMsg(num) {
                    console.log(num);
                }
            }
        })
    </script>
</body>

</html>